<template>
  <div style="height: calc(100vh - 180px);">
    <vTable   
           class="no-border-top"
          :columnsList="columnsList"
          apiUrl="boss/tanc_plantint_plan_logs/list"
          :pageSize="15"
          :toolbarConfig="false"
          :queryData="{
            param2: userStore.userInfo.farmId,
            lovCode: 'TANC_FARM_USER',
            plantingPlanId: plantHeaderId
           }">
      </vTable>
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/pinia/modules/user'
import { getPlantLogList } from '@/api/plant'
import { message } from '@/utils/element'
import { ElMessageBox } from 'element-plus'
import cTable from '@/components/custom/cTable.vue'
const router = useRouter()
const route = useRouter()
const userStore = useUserStore()
const page = ref(1)
const limit = ref(10)
const total = ref(0)
const plantHeaderId = ref('')
const tableData = ref([])
const loading = ref(true)
const tableRef = ref(null)
const columnsList = ref([
      {type: 'seq', title: '序号',width:'60',align:'center'},
      {field: 'realName', title: '操作人',width:'180',align:'center'},
      {field: 'createTime', title: '操作时间',width:'300',align:'center'},
      {field: 'content', title: '内容',minWidth:'160',align:'left'}
   ])
onMounted(() => {
  plantHeaderId.value = route.currentRoute.value.query.plantHeaderId
  getTableData()
})

// 分页
const handleSizeChange = (val) => {
  page.value = 1
  limit.value = val
  getTableData()
}

const handleCurrentChange = (val) => {
  page.value = val
  getTableData()
}

// 查询
const getTableData = async() => {
  const res = await getPlantLogList({
    page: page.value,
    limit: limit.value,
    param2: userStore.userInfo.farmId,
    lovCode: 'TANC_FARM_USER',
    plantingPlanId: plantHeaderId.value
  })
  if (res.code == 0) {
    tableData.value = res.data
    total.value = res.total
  }
  loading.value = false
}
</script>
